package myschool.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "HelloServlet2",value = {"/wenhao","/wenhou","/goodmorning"})
public class HelloServlet2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<div style='color:red;'>83班同学，下午好</div>");
        out.print("<h1>");
        out.print("你好，我不是渣渣灰，This is a post请求");
        out.print("</h1>");
        out.print("</body>");
        out.print("</html>");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //ServletContext servletContext = request.getServletContext();
        //servletContext.getRealPath("");

        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<div style='color:red;'>83班同学，下午好</div>");
        out.print("<h1>");
        out.print("你好，我不是渣渣灰，This is a get请求");
        out.print("</h1>");
        out.print("</body>");
        out.print("</html>");
    }
}
